#include <winsock2.h>
#include <interfacelib/frame/handlemanager.h>

using namespace interfacelib::Frame;

HandleManager::HandleManager() : m_windowHandle( NULL ), m_windowInstance( NULL ), functionPreRelease( NULL )
{
}

HandleManager::~HandleManager()
{
}

void HandleManager::initialize( HINSTANCE windowInstance, HWND windowHandle )
{
	m_windowHandle = windowHandle;
	m_windowInstance = windowInstance;
}

HWND HandleManager::getWindowHandle()
{
	return ( m_windowHandle );
}

HINSTANCE HandleManager::getWindowInstance()
{
	return ( m_windowInstance );
}

bool HandleManager::postMessage( unsigned int msgID, WPARAM wparam, LPARAM lparam )
{
	if ( !m_windowHandle ) return ( false );
	PostMessage( m_windowHandle, msgID, wparam, lparam );
	return ( true );
}

void HandleManager::preRelease()
{
	if ( functionPreRelease ) functionPreRelease();
}

void HandleManager::setPreRelease(  void ( *setFunctionPreRelease )() )
{
	functionPreRelease = setFunctionPreRelease;
}